<template>
	<view>
		<view class="color-zs" @click="$getCode()">{{tip}}</view>
		<u-verification-code seconds="60" ref="uCode" @change="e=>tip=e" />
	</view>
</template>

<script>
	export default {
		name: "tips",
		props: {
			mobile: {
				default: ''
			},
			type: {
				default: ''
			},
		},
		data() {
			return {
				tip: ''
			};
		},
		methods: {
			$getCode() { //发送验证码
				//type 绑定手机号：bind，注册：register，忘记密码：forget，修改手机号：modify，绑定银行卡：bank
				let {
					mobile,
					type,
				} = this
				let uCode = this.$refs.uCode
				if (!uCode) return
				// if (!mobile) return this.$u.toast('请输入手机号');
				if (uCode.canGetCode) {
					uni.showLoading({
						title: '正在获取验证码'
					})
					let form = {
						mobile,
						type: 'm_' + type,
						...this.$attrs
					}
					// return this.$msg('密码123456')
					this.$request('/system/sms/send_sms', form).then(res => {
						uni.hideLoading();
						uCode.start();
						this.$u.toast(res.msg);
					})
				} else {
					this.$u.toast('倒计时结束后再发送');
				}
			},
		}
	}
</script>

<style lang="scss">

</style>